<script type="text/html" template>
    <link rel="stylesheet" href="{{ layui.setter.base }}style/css/reset.css">
    <link rel="stylesheet" href="{{ layui.setter.base }}style/css/maintain/google.css">
    <link rel="stylesheet" href="{{ layui.setter.base }}style/page.css">
</script>
<style scoped>
    .search{
      width: 60px;
      font-size: 11px;
      margin: 0;
      padding: 0 5px;
      border: 0;
      text-align: center;
      background-color: #FF4C4C;
      margin-top: 15px;
      line-height: 22px;
      height: 22px;
    }
</style>
<div class="box layui-fluid layui-row leon-fluid">
    <div class="layui-btn-container layui-col-sm12 layui-col-md12" style="text-align: left;">
        <button class="add-btn layui-btn layui-btn-radius layui-btn-primary">
            <i class="layui-icon layui-icon-add-circle" style="font-size: 15px; color: #1E9FFF;"></i>
            <span>添加报修</span>
        </button>
    </div>
    <form class="form layui-form layui-col-sm12 layui-col-md12">
        <div class="layui-form-item layui-col-sm3 layui-col-md3">
            <label class="layui-form-label">工单状态：</label>
            <div class="layui-input-block">
                <select name="fil05">
                    <option value="">全部</option>
                    <option value="0">创建/未提交</option>
                    <option value="1">待审核</option>
                    <option value="2">待执行</option>
                    <option value="3">外修</option>
                    <option value="4">待确认</option>
                    <option value="7">超时未完成</option>
                    <option value="8">超时已完成</option>
                    <option value="9">归档/已盘点</option>
                  </select>
            </div>
        </div>
        <div class="layui-form-item layui-col-sm3 layui-col-md3 ">
            <label class="layui-form-label">工单编号:</label>
            <div class="layui-input-block layui-col-space14">
                <input type="text" name="fil01" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-col-sm3 layui-col-md3 ">
            <label class="layui-form-label ">设备编号：</label>
            <div class="layui-input-block layui-col-space14">
                <input type="text" name="fil03" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-btn-container layui-col-sm3 layui-col-md3 " style="display: flex;justify-content: flex-start; ">
            <button class="search-btn layui-btn layui-btn-radius layui-btn-primary" lay-submit
                lay-filter="queryTable">
                <i class="layui-icon layui-icon-search " style="font-size: 10px; color: #FFF; "></i>
                <span>查询</span>
            </button>
        </div>
    </form>
    <table class="layui-table" id="table-list" lay-filter="table-list"></table>
    <div class="footer layui-btn-container">
        <button class="search layui-btn layui-btn-radius layui-btn-primary">
            <i class="layui-icon layui-icon-delete" style="font-size: 15px; color: #FFF;"></i>
            <span class="labelinp" data_cn="打印" data_en="print" data-lang="toggle">删除</span>
        </button>
    </div>
</div>

<script>
        layui.use(['form', 'table', 'api', 'utill', 'admin', 'view','admin'], function() { //此段代码必不可少
            var table = layui.table,
                setter = layui.setter,
                laytpl = layui.laytpl,
                api = layui.api,
                utill = layui.utill,
                form = layui.form,
                element = layui.element,
                laypage = layui.laypage,
                form = layui.form,
                admin = layui.admin,
                view = layui.view;
                utill.showAndHide('.add-btn',"FilFileController:insertRepairs");
            form.render();

            var _TPL = {
                fil05: function(d) {
                    if (d.fil05 == 0) {
                        return '<span>创建/未提交</span>'

                    } else if (d.fil05 == 1) {
                        return '<span>待审核</span>'
                    
                    } else if (d.fil05 == 2) {
                        return "<span style='color:blue'>待执行</span>";
                    
                    } else if (d.fil05 == 3) {
                        return '<span>外修</span>'
                    
                    } else if (d.fil05 == 4) {
                        return '<span>待确认</span>'
                    
                    } else if (d.fil05 == 5) {
                        return '<span>待领料</span>'
                    
                    } else if (d.fil05 == 6) {
                        return '<span>OA送审中</span>'
                    
                    } else if (d.fil05 == 7) {
                        return '<span style="color:red;">超时未完成</span>'
                    
                    }else if (d.fil05 == 8) {
                        return '<span style="color:orange;">超时已完成</span>'
                    
                    }else if (d.fil05 == 9) {
                        return '<span style="color:green;">归档</span>'
                    } else {
                        return '';
                    }
                },
                fil06: function(d) {
                    if (d.fil06 == '0') {
                        return '<span style="color:green">正常</span>'
                    } else if (d.fil06 == '1') {
                        return '<span style="color:#ff4100">重要</span>'
                    } else if (d.fil06 == '2') {
                        return '<span style="color:red">紧急</span>'
                    } else　{
                        return ''
                    }
                }
            }
            // 列定制
            utill.columnCustom('#table-list', "FilFileWXDetailListV", {
                url: api.host + api.gzbx.FilFileWxSelectWxList,
                id: 'table-list',
                where: {
                    fil05: "",
                    fil01: "",
                    fil03: "",
                },
                templet: _TPL
            });

            form.on('submit(queryTable)', function(data) {
                var allData = data.field;
                table.reload('#table-list', {
                    where: allData,
                });
                return false;
            })
            table.on('tool(table-list)', function(obj){
                var data = obj.data;
                if ( obj.event == 'detail' ) {
                    $(this).attr('lay-href', 'maintain/branch-six/form-one/fil01=' + data.fil01 + '/gen01='+ data.gen01+ '/tcReqId='+ data.tcReqId+ '/fil05='+ data.fil05);
                }
            })
            //删除按钮
            $('.footer').on('click','.search',function(){
                // var data = table.cache['#table-list'];
                var checkStatus = table.checkStatus('#table-list').data;
                var fil01 = [];
                var fil05 = [];
                checkStatus.forEach(elem=>{
                    fil01.push(elem.fil01);
                    fil05.push(elem.fil05);
                })
                if(fil05 && fil01 == '' || fil05 && fil01 == null){
                    layer.msg('请选择您要删除的工单!')
                }else{
                    admin.req({
                        url: api.host + api.gzbx.del,
                        contentType: 'application/json',
                        dataType: 'json',
                        type: 'post',
                        data: JSON.stringify({fil05:fil05,fil01:fil01}),
                        success: function (res) {
                            if(res.data == 0){
                                table.render()
                                table.reload('#table-list');
                            }
                        }
                });
                }
            })
            $('.layui-table').on('click', '.layui-icon-made', function() {
            layer.open({
                type: 2,
                title: false,
                area: ['368px', '284px'],
                fixed: true,
                shadeClose: true,
                closeBtn: 0,
                content: ['./src/views/home/alert/Customized.html', 'no']
            });
        });
        $('.layui-btn-container .add-btn').attr('lay-href', 'maintain/branch-six/add-project');
        });

       
</script>
<style>
    .leon-fluid .layui-table-tool {
        min-height: auto;
        line-height: inherit;
        padding: 0;
        border-width: 0;
    }
    
    .leon-fluid .layui-table-tool .layui-table-tool-temp {
        position: absolute;
        top: calc(100vh - 140px);
        left: 13px;
    }
    
    .leon-fluid .table-toolbar-wrapper {
        margin-top: 0;
    }
    .custom-msg {
        border-radius: 6px;
        border: 0;
        width: 250px;
    }
    
    .custom-msg .layui-layer-content {
        text-align: center;
    }
    
    .custom-msg .layui-layer-btn a {
        height: 28px;
        border-radius: 14px;
        font-size: 14px;
        line-height: 28px;
    }
    
    .custom-msg .layui-layer-btn a.layui-layer-btn0 {
        background: #FF4C4C;
        border: 0;
        margin-right: 50px;
    }
    
    .custom-layer {
        background: none;
    }
</style>